package date.time.clock;

import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.DatePicker.OnDateChangedListener;
import android.widget.TimePicker;

public class TimesActivity extends Activity {
	
	private DatePicker  date1;
	private TimePicker  time1;
	private Button button1,button2;
	Calendar cal;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        date1=(DatePicker)findViewById(R.id.datepickertext);
        time1=(TimePicker)findViewById(R.id.timepickertext);
        button1=(Button)findViewById(R.id.button1);
        button2=(Button)findViewById(R.id.button2);
        cal=Calendar.getInstance();
        
        date1.init(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 
        		cal.get(Calendar.DAY_OF_MONTH),
        		       new DatePicker.OnDateChangedListener()
        {
        	public void onDateChanged(DatePicker view,int year,int monthOfYear,int dayOfMonth)
        	{
        		date1.updateDate(year, monthOfYear, dayOfMonth);
        	}
        	
        });
        
         button1.setOnClickListener(new OnClickListener()
         {
        	 public void onClick(View v)
        	 {
        		 new DatePickerDialog(TimesActivity.this,
        				 new DatePickerDialog.OnDateSetListener() {
							
							public void onDateSet(DatePicker view, int year,
									int monthOfYear,
									int dayOfMonth) {
								// TODO Auto-generated method stub
								date1.updateDate(year, monthOfYear, dayOfMonth);
								
							}
						}, 
						cal.get(Calendar.YEAR), 
						cal.get(Calendar.MONTH), 
						cal.get(Calendar.DAY_OF_MONTH)
						).show();
        	 }
         });  
        
        
    }
    
}